package com.cadre.common.utils.oldutil;

import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark;
import sun.misc.BASE64Decoder;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Map;

/* loaded from: PhotoHandler.class */
public class PhotoHandler implements CellHandler {
    @Override // com.tdqy.cadre.modular.profess.common.report.CellHandler
    public void setValue(XWPFParagraph paragraph, Map data) {
        XWPFRun run = paragraph.createRun();
        CTBookmark bookmark = paragraph.getCTP().getBookmarkStartArray(0);
        if (data.get(bookmark.getName()) != null) {
            byte[] b = null;
            try {
                b = new BASE64Decoder().decodeBuffer(data.get(bookmark.getName()).toString());
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                run.addPicture(new ByteArrayInputStream(b), 5, "pic", Units.toEMU(103.0d), Units.toEMU(140.0d));
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
    }
}
